﻿Imports Clases
Public Class frmVerPedido
    ''' <summary>
    ''' Cargamos los pedidos en el caso de que exista alguno
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub frmVerPedido_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Me.Text &= usuarioActivo.Nombre

        If misPedidos.Pedidos.Count > 0 Then
            Dim xlbUsu As Integer = 25
            Dim xlbFecha As Integer
            Dim yPoint As Integer = 15
            Dim xlbCant As Integer
            Dim xlbProd As Integer
            Dim xlbPrecio As Integer
            For i As Byte = 0 To misPedidos.Pedidos.Count - 1
                Dim lblUsu As New Label
                lblUsu.Visible = True
                lblUsu.Name = "usuario"
                lblUsu.Text = misPedidos.Pedidos(i).NombreCliente
                lblUsu.Size = New Size(70, 20)
                lblUsu.Location = New Point(xlbUsu, yPoint)
                gbPedido.Controls.Add(lblUsu)

                xlbFecha = lblUsu.Width + 100

                Dim lblFecha As New Label
                lblFecha.Visible = True
                lblFecha.Name = "fecha"
                lblFecha.Text = misPedidos.Pedidos(i).FechaPedido
                lblFecha.Size = New Size(70, 20)
                lblFecha.Location = New Point(xlbFecha, yPoint)
                gbPedido.Controls.Add(lblFecha)
                yPoint += lblUsu.Height + 10
                xlbProd = xlbUsu + 10
                For u As Byte = 0 To misPedidos.Pedidos(i).ListaProductos.Count - 1
                    Dim lblProd As New Label
                    lblProd.Visible = True
                    lblProd.Name = "pedido"
                    lblProd.Text = misPedidos.Pedidos(i).ListaProductos(u).Nombre
                    lblProd.Size = New Size(70, 20)
                    lblProd.Location = New Point(xlbProd, yPoint)
                    gbPedido.Controls.Add(lblProd)

                    xlbPrecio = lblProd.Width + 100
                    Dim lblPrecio As New Label
                    lblPrecio.Visible = True
                    lblPrecio.Name = "precio"
                    lblPrecio.Text = misPedidos.Pedidos(i).ListaProductos(u).Precio & "€"
                    lblPrecio.Size = New Size(70, 20)
                    lblPrecio.Location = New Point(xlbPrecio, yPoint)
                    gbPedido.Controls.Add(lblPrecio)

                    xlbCant = lblPrecio.Width + 200

                    Dim lblCant As New Label
                    lblCant.Visible = True
                    lblCant.Name = "cantidad"
                    lblCant.Text = misPedidos.Pedidos(i).ListaProductos(u).Cantidad & " unidades"
                    lblCant.Size = New Size(70, 20)
                    lblCant.Location = New Point(xlbCant, yPoint)
                    gbPedido.Controls.Add(lblCant)
                    yPoint += lblProd.Height + 10
                Next
                Dim lblTotal As New Label
                lblTotal.Name = "precioTotal"
                lblTotal.Visible = True
                lblTotal.Text = "Precio total: " & misPedidos.Pedidos(i).PrecioTotal & "€"
                lblTotal.Size = New Size(150, 20)
                lblTotal.Location = New Point(xlbUsu, yPoint)
                gbPedido.Controls.Add(lblTotal)
                yPoint += lblTotal.Height + 10
            Next
        Else
            MessageBox.Show("No hay pedidos", "Ver pedidos")
        End If
    End Sub

    
    Private Sub gbPedido_Enter(sender As System.Object, e As System.EventArgs) Handles gbPedido.Enter

    End Sub
End Class